# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=mousejack
pkgver=5.58b69c1
pkgrel=4
pkgdesc='Wireless mouse/keyboard attack with replay/transmit poc.'
groups=('blackarch' 'blackarch-wireless')
arch=('any')
url='https://github.com/iamckn/mousejack_transmit'
license=('custom:unknown')
depends=('python2' 'python2-pyusb')
makedepends=('git')
source=("$pkgname::git+https://github.com/iamckn/mousejack_transmit.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" readme.md

  rm readme.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/mousejack-replay" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 mousejack-replay.py "\$@"
EOF

  cat > "$pkgdir/usr/bin/mousejack-nrf24-replay" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 nrf24-replay.py "\$@"
EOF

  cat > "$pkgdir/usr/bin/mousejack-nrf24-scanner" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 nrf24-scanner.py "\$@"
EOF
  cat > "$pkgdir/usr/bin/mousejack-nrf24-sniffer" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 nrf24-sniffer.py "\$@"
EOF
  cat > "$pkgdir/usr/bin/mousejack-nrf24-static-channel-replay" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 nrf24-static-channel-replay.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"*
}

